package com.ruoyi.web.controller.app;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.AppCourseConsume;
import com.ruoyi.common.core.domain.vo.AppCourseConsumeVo;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.service.IAppCourseConsumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/app/course/consume")
public class AppCourseConsumeController extends BaseController {
    @Autowired
    private IAppCourseConsumeService appCourseConsumeService;

    @PreAuthorize("@ss.hasPermi('system:course:consume:list')")
    @GetMapping("/list")
    public TableDataInfo list(AppCourseConsume appCourseConsume) {
        startPage();
        List<AppCourseConsumeVo> appCourseConsumeList = appCourseConsumeService.selectCurseConsumeList(appCourseConsume);
        return getDataTable(appCourseConsumeList);
    }

    @PreAuthorize("@ss.hasPermi('system:course:consume:changeStatus')")
    @GetMapping("/changeStatus")
    @Log(title = "课程管理", businessType = BusinessType.UPDATE)
    public AjaxResult changeStatus(@RequestBody AppCourseConsume appCourseConsume) {
        appCourseConsume.setUpdateBy(getUsername());
        return toAjax(appCourseConsumeService.changeStatus(appCourseConsume));
    }

}
